package org.fuys.coder.infrastructure.repository;

import org.fuys.coder.domain.auth.repository.ITokenRepository;
import org.fuys.coder.infrastructure.util.RedisUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.infrastructure.repository
 * @className: TokenRepository
 * @author: WangJing
 * @description: token仓储
 * @date: 2024/9/6 16:29
 * @version: 1.0
 */
@Service
public class TokenRepository implements ITokenRepository {

    @Resource
    private RedisUtil redisUtil;


    @Override
    public void setToken(String key, String value) {
        redisUtil.commonSet(key,value);
    }

    @Override
    public void setToken(String key, String value, long time, TimeUnit timeUnit) {
        redisUtil.commonSet(key,value,time,timeUnit);
    }

    @Override
    public Object getToken(String key) {
        return redisUtil.commonGet(key);
    }

    @Override
    public void deleteToken(String key) {
        redisUtil.deleteKey(key);
    }
}
